package com.demister.at.model;

/**
 *
 * @author Rock
 */
public abstract class BlockTypeSchema {

    private BlockDecorator decorator = new BlockDecoratorImp();

    public BlockTypeSchema() {
    }

    public abstract boolean isRemoveType(int type);

    public abstract boolean isRemovableSameType(int type1, int type2);

    public abstract boolean isCombinableSameType(int type1, int type2);

    public abstract boolean isSameMajorType(int type1, int type2);

    public abstract boolean isSameType(int type1, int type2);

    public abstract boolean isDisable(int type);

    public abstract int getDisableCount(int type);
    
    public abstract int setDisableCount(int type, int count);

    public abstract int getMajorType(int type);

    public abstract int getMinorType(int type);

    public BlockDecorator getBlockDecorator(Block b) {
        this.decorator.setBlock(b);
        return this.decorator;
    }

    class BlockDecoratorImp extends BlockDecorator {

        @Override
        public boolean isRemoveType() {
            return BlockTypeSchema.this.isRemoveType(block.getType());
        }

        @Override
        public boolean isRemovableSameType(Block b) {
            return BlockTypeSchema.this.isRemovableSameType(block.getType(), b.getType());
        }

        @Override
        public boolean isCombinableSameType(Block b) {
            return BlockTypeSchema.this.isCombinableSameType(block.getType(), b.getType());
        }

        @Override
        public boolean isSameMajorType(Block b) {
            return BlockTypeSchema.this.isSameMajorType(block.getType(), b.getType());
        }

        @Override
        public boolean isSameType(Block b) {
            return BlockTypeSchema.this.isSameType(block.getType(), b.getType());
        }

        @Override
        public boolean isDisable() {
            return BlockTypeSchema.this.isDisable(block.getType());
        }

        @Override
        public int getDisableCount() {
            return BlockTypeSchema.this.getDisableCount(block.getType());
        }

        @Override
        public int setDisableCount(int count) {
            int newType = BlockTypeSchema.this.setDisableCount(block.getType(), count);
            block.setType(newType);
            return newType;
        }

        @Override
        public int getMajorType() {
            return BlockTypeSchema.this.getMajorType(block.getType());
        }

        @Override
        public int getMinorType() {
            return BlockTypeSchema.this.getMinorType(block.getType());
        }

    }
}

